package com.xlf.controller.admin;


import com.xlf.domain.Seat;
import com.xlf.service.SeatService;
import com.xlf.utils.ResponseResult;
import com.xlf.vo.QueryPageBean;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 店铺座位控制层
 */

@RestController
@RequestMapping("/seat")
public class SeatController {

    @Resource
    SeatService seatService;

    /**
     * 条件查询座位，支持分页、时间区间、分类/标签id查询
     * @param queryPageBean 分页查询条件对象
     * @return              分页查询结果
     */
    @PostMapping("/getSeatPage")
    public ResponseResult getSeatPage(@RequestBody QueryPageBean queryPageBean){
        return ResponseResult.success("获取seat分页成功",seatService.getSeatPage(queryPageBean));
    }

    /**
     * 根据作为id/id列表删除座位
     * @param id    id/id列表
     * @return      执行结果
     */
    @DeleteMapping("/delete")
    public ResponseResult deleteSeat(@RequestBody List<Long> id){
        seatService.removeByIds(id);
        return ResponseResult.success("删除成功");
    }

    /**
     * 新增或修改座位
     * @param seat  座位对象，通过有没有id来判断是新增还是修改
     * @return      执行结果
     */
    @PostMapping("/savaOrUpdate")
    public ResponseResult savaOrUpdate(@RequestBody Seat seat){
        seatService.saveOrUpdate(seat);
        return ResponseResult.success("新增/修改成功");
    }

}
